<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.5"/>
<title>xilsecure: xsecure_lms_core.c File Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
  $(window).load(resizeHeight);
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="HTML_custom.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="xlogo_bg.png"/></td>
  <td style="padding-left: 0.5em;">
   <div id="projectname">xilsecure
   </div>
   <div id="projectbrief">Vitis Drivers API Documentation</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.5 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Overview</span></a></li>
      <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
      <li><a href="globals.html"><span>APIs</span></a></li>
      <li><a href="files.html"><span>File&#160;List</span></a></li>
    </ul>
  </div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;"
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('xsecure__lms__core_8c.html','');});
</script>
<div id="doc-content">
<div class="header">
  <div class="summary">
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">xsecure_lms_core.c File Reference</div>  </div>
</div><!--header-->
<div class="contents">
<a name="details" id="details"></a><h2 class="groupheader">Overview</h2>
<div class="textblock"><p>This file consists definitions of LMS authentication routines. </p>
<pre>
MODIFICATION HISTORY:</pre><pre>Ver   Who  Date        Changes
----- ---- -------- -------------------------------------------------------
5.4   kal  07/24/24  Initial release
      kal  01/30/25  Update LMS/HSS APIs to accept the original data instead
                     of pre calculated hash.</pre><pre></pre> <dl class="section note"><dt>Note</dt><dd></dd></dl>
</div><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:a6b50f9fb052dd231c50ea15138f17ff7"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="xsecure__lms__core_8c.html#a6b50f9fb052dd231c50ea15138f17ff7">XSecure_LmsSignatureVerification</a> (XSecure_Sha *ShaInstPtr, XPmcDma *DmaPtr, XSecure_LmsSignVerifyParams *LmsSignVerifyParams)</td></tr>
<tr class="memdesc:a6b50f9fb052dd231c50ea15138f17ff7"><td class="mdescLeft">&#160;</td><td class="mdescRight">This function performs LMS level signature verification.  <a href="#a6b50f9fb052dd231c50ea15138f17ff7">More...</a><br/></td></tr>
<tr class="separator:a6b50f9fb052dd231c50ea15138f17ff7"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a981b22fbc50d9cd6f91c16604754f078"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="xsecure__lms__core_8c.html#a981b22fbc50d9cd6f91c16604754f078">XSecure_HssInit</a> (XSecure_Sha *ShaInstPtr, XPmcDma *DmaPtr, XSecure_HssInitParams *HssInitParams)</td></tr>
<tr class="memdesc:a981b22fbc50d9cd6f91c16604754f078"><td class="mdescLeft">&#160;</td><td class="mdescRight">This function Initiates LMS Signature verification process.  <a href="#a981b22fbc50d9cd6f91c16604754f078">More...</a><br/></td></tr>
<tr class="separator:a981b22fbc50d9cd6f91c16604754f078"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a20f145ad946cac0682c7428afe35dc8f"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="xsecure__lms__core_8c.html#a20f145ad946cac0682c7428afe35dc8f">XSecure_LmsHashMessage</a> (XSecure_Sha *ShaInstPtr, u8 *Data, u32 DataLen, XSecure_ShaMode Mode)</td></tr>
<tr class="memdesc:a20f145ad946cac0682c7428afe35dc8f"><td class="mdescLeft">&#160;</td><td class="mdescRight">This function calculates the Digest of data to authenticate to initiate the process of LMS verification.  <a href="#a20f145ad946cac0682c7428afe35dc8f">More...</a><br/></td></tr>
<tr class="separator:a20f145ad946cac0682c7428afe35dc8f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a112da8c38a140d02852bd8f93ab78e2f"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="xsecure__lms__core_8c.html#a112da8c38a140d02852bd8f93ab78e2f">XSecure_HssFinish</a> (XSecure_Sha *ShaInstPtr, XPmcDma *DmaPtr, u8 *SignBuff, u32 SignatureLen)</td></tr>
<tr class="memdesc:a112da8c38a140d02852bd8f93ab78e2f"><td class="mdescLeft">&#160;</td><td class="mdescRight">This function Completes LMS Signature verification process.  <a href="#a112da8c38a140d02852bd8f93ab78e2f">More...</a><br/></td></tr>
<tr class="separator:a112da8c38a140d02852bd8f93ab78e2f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a4fe7fa250fbd0908fb92b6f65becf08e"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="xsecure__lms__core_8c.html#a4fe7fa250fbd0908fb92b6f65becf08e">XSecure_GetLmsHashAlgo</a> (u32 PubAlgo, const u8 *const PubKey, XSecure_ShaMode *SignAlgo)</td></tr>
<tr class="memdesc:a4fe7fa250fbd0908fb92b6f65becf08e"><td class="mdescLeft">&#160;</td><td class="mdescRight">This function returns public key LMS type.  <a href="#a4fe7fa250fbd0908fb92b6f65becf08e">More...</a><br/></td></tr>
<tr class="separator:a4fe7fa250fbd0908fb92b6f65becf08e"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<h2 class="groupheader">Function Documentation</h2>
<a class="anchor" id="a4fe7fa250fbd0908fb92b6f65becf08e"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int XSecure_GetLmsHashAlgo </td>
          <td>(</td>
          <td class="paramtype">u32&#160;</td>
          <td class="paramname"><em>PubAlgo</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const u8 *const&#160;</td>
          <td class="paramname"><em>PubKey</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">XSecure_ShaMode *&#160;</td>
          <td class="paramname"><em>SignAlgo</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>This function returns public key LMS type. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">PubAlgo</td><td>- Algorithm selected by current PDI </td></tr>
    <tr><td class="paramname">PubKey</td><td>- pointer to PPK location, PPK is used to detect the variant of LMS selected</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd><ul>
<li>XST_SUCCESS - If operation success, otherwise following errors</li>
<li>XSECURE_LMS_KAT_PUB_KEY_UNSUPPORTED_LMS_TYPE_ERROR </li>
</ul>
</dd></dl>
<p>Public key's LMS type</p>
<p>LMS Parameters extracted from Public Key </p>

<p>References <a class="el" href="group__xsecure__error__codes.html#ggacba8dc046b878afa42fdc63ce1dc2574a6dea4359a1cea07a02d4a26c5acc848b">XSECURE_LMS_HSS_L0_PUB_KEY_LMS_TYPE_UNSUPPORTED_ERROR</a>, <a class="el" href="xsecure__lms_8h.html#a87557e3db575e6dc9ad6ddfc596a554aa2c49e5b42557925b34b58f162bb3fc31">XSECURE_LMS_NOT_SUPPORTED</a>, <a class="el" href="xsecure__lms_8c.html#a292e1e3bc9bd3759b76c98cfd8196deb">XSecure_LmsLookupParamSet()</a>, and <a class="el" href="group__xsecure__common__apis.html#ga693c54d224d1fa8ca68b215023b2b359">XSecure_Printf</a>.</p>

</div>
</div>
<a class="anchor" id="a112da8c38a140d02852bd8f93ab78e2f"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int XSecure_HssFinish </td>
          <td>(</td>
          <td class="paramtype">XSecure_Sha *&#160;</td>
          <td class="paramname"><em>ShaInstPtr</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">XPmcDma *&#160;</td>
          <td class="paramname"><em>DmaPtr</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">u8 *&#160;</td>
          <td class="paramname"><em>SignBuff</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">u32&#160;</td>
          <td class="paramname"><em>SignatureLen</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>This function Completes LMS Signature verification process. </p>
<pre class="fragment">    Data should have been pre-processed before calling this function, by
    calling @ref XSecure_HssInit &amp; @ref XSecure_LmsHashMessage in sequence
</pre><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">SignBuff</td><td>- Pointer to Signature buffer </td></tr>
    <tr><td class="paramname">SignatureLen</td><td>- Length of signature buffer</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>XST_SUCCESS - If operation success, otherwise following errors </dd></dl>
<p>Signature Length should be at least 4 bytes </p>

<p>References <a class="el" href="struct_x_secure___lms_param.html#a42a5db17d1cf707af99fddeb1a50315e">XSecure_LmsParam::mh</a>, <a class="el" href="group__xsecure__error__codes.html#ggacba8dc046b878afa42fdc63ce1dc2574a867397d1c5d08fd88cdee4694314eeff">XSECURE_LMS_HSS_L0_PUB_KEY_AUTH_FAILED_ERROR</a>, <a class="el" href="group__xsecure__error__codes.html#ggacba8dc046b878afa42fdc63ce1dc2574adfc7f0aec695048344c249c41e2c978a">XSECURE_LMS_HSS_L1_PUB_KEY_LMS_OTS_TYPE_UNSUPPORTED_ERROR</a>, <a class="el" href="group__xsecure__error__codes.html#ggacba8dc046b878afa42fdc63ce1dc2574a1a9aa90f5ad11fbbd676f0924422f8f3">XSECURE_LMS_HSS_L1_PUB_KEY_LMS_TYPE_2_UNSUPPORTED_ERROR</a>, <a class="el" href="group__xsecure__error__codes.html#ggacba8dc046b878afa42fdc63ce1dc2574a52cea29488d9d09504cc25b98ba237a7">XSECURE_LMS_HSS_L1_SIGN_INVALID_LEN_2_ERROR</a>, <a class="el" href="group__xsecure__error__codes.html#ggacba8dc046b878afa42fdc63ce1dc2574a958288d2bb37e171f3218ccd44da3e94">XSECURE_LMS_HSS_OTS_SIGN_INVALID_LEN_1_ERROR</a>, <a class="el" href="xsecure__lms_8h.html#a87557e3db575e6dc9ad6ddfc596a554aa2c49e5b42557925b34b58f162bb3fc31">XSECURE_LMS_NOT_SUPPORTED</a>, <a class="el" href="xsecure__lms__ots_8h.html#ac44fed4428b1bce22f588c3c913818fdab0be342315c7753f9987ad7d713b6fbd">XSECURE_LMS_OTS_NOT_SUPPORTED</a>, <a class="el" href="xsecure__lms_8c.html#a292e1e3bc9bd3759b76c98cfd8196deb">XSecure_LmsLookupParamSet()</a>, <a class="el" href="xsecure__lms__ots_8c.html#a48db68f8b63048019c35a756e58d9181">XSecure_LmsOtsLookupParamSet()</a>, <a class="el" href="xsecure__lms__core_8c.html#a6b50f9fb052dd231c50ea15138f17ff7">XSecure_LmsSignatureVerification()</a>, and <a class="el" href="group__xsecure__common__apis.html#ga693c54d224d1fa8ca68b215023b2b359">XSecure_Printf</a>.</p>

<p>Referenced by <a class="el" href="group__xsecure__kat__server__apis.html#gacd410c8890a3160304bf000bf0af2031">XSecure_HssSha2256Kat()</a>, and <a class="el" href="group__xsecure__kat__server__apis.html#ga75f8f635a7d2a99f8b2011b8365a7c46">XSecure_HssShake256Kat()</a>.</p>

</div>
</div>
<a class="anchor" id="a981b22fbc50d9cd6f91c16604754f078"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int XSecure_HssInit </td>
          <td>(</td>
          <td class="paramtype">XSecure_Sha *&#160;</td>
          <td class="paramname"><em>ShaInstPtr</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">XPmcDma *&#160;</td>
          <td class="paramname"><em>DmaPtr</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">XSecure_HssInitParams *&#160;</td>
          <td class="paramname"><em>HssInitParams</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>This function Initiates LMS Signature verification process. </p>
<pre class="fragment">            Completes all upper level Merkle trees verification and prepares
            for data's Digest calculation
</pre><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">Signature</td><td>- Pointer to Signature buffer </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">SignatureLen</td><td>- Length of signature buffer </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">PublicKey</td><td>- Pointer to public key buffer </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">PublicKeyLen</td><td>- Length of public key buffer</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd><ul>
<li>XST_SUCCESS - If operation success, otherwise following errors </li>
</ul>
</dd></dl>
<p>Signature structure u32str(Nspk) || signed_pub_key[0] || ... || signed_pub_key[Nspk-1] || sig[Nspk] u32str(Nspk) || sig[0] || pub[1] || ... || sig[Nspk-1] || pub[Nspk] || sig[Nspk]</p>
<p>Public key of lower level is used as a message to be authenticated, and signature of that level to back calculate the public key at that level. if this is happening for top most tree then value will be HSS public key saved as PPK or SPK, in turn all the levels above [levels - 1] are verified, so when the actual message is verified using lowest tree's leaf node, as the public key for that tree (lowest) is already verified, message is authenticated.</p>
<p>PLM Supports two levels trees, level-0 &amp; 1 namely. For KAT, only 1 levels is required, which is level-0. for KAT the following condition is skipped</p>
<p>Parse HSS/Current level's public key provided, determine the expected signature length of sig[0]</p>

<p>References <a class="el" href="union_x_secure___lms_data_digest_fixed_fields__.html#a47f35181622252a6c7fbe981d2287fb5">XSecure_LmsDataDigestFixedFields_::C</a>, <a class="el" href="union_x_secure___lms_public_key__.html#ac6ae68c15b5e75b23152118487ef1760">XSecure_LmsPublicKey_::I</a>, <a class="el" href="union_x_secure___lms_data_digest_fixed_fields__.html#aaa6fe65d46b47201f9c1759148669987">XSecure_LmsDataDigestFixedFields_::I</a>, <a class="el" href="struct_x_secure___lms_param.html#a42a5db17d1cf707af99fddeb1a50315e">XSecure_LmsParam::mh</a>, <a class="el" href="union_x_secure___lms_data_digest_fixed_fields__.html#aba71ec3514983a2b92250d07d56441fb">XSecure_LmsDataDigestFixedFields_::q</a>, <a class="el" href="group___l_m_s.html#ga46fcdbeb8c2bcadbe7d087915c3eefd3">XSECURE_HSS_PUBLIC_KEY_TOTAL_SIZE</a>, <a class="el" href="group__xsecure__error__codes.html#ggacba8dc046b878afa42fdc63ce1dc2574a867397d1c5d08fd88cdee4694314eeff">XSECURE_LMS_HSS_L0_PUB_KEY_AUTH_FAILED_ERROR</a>, <a class="el" href="group__xsecure__error__codes.html#ggacba8dc046b878afa42fdc63ce1dc2574a78bf5b8f8b158337aa879149df9d7a0c">XSECURE_LMS_HSS_L0_PUB_KEY_LMS_OTS_TYPE_UNSUPPORTED_ERROR</a>, <a class="el" href="group__xsecure__error__codes.html#ggacba8dc046b878afa42fdc63ce1dc2574a6dea4359a1cea07a02d4a26c5acc848b">XSECURE_LMS_HSS_L0_PUB_KEY_LMS_TYPE_UNSUPPORTED_ERROR</a>, <a class="el" href="group__xsecure__error__codes.html#ggacba8dc046b878afa42fdc63ce1dc2574aa43c6fd9a4e0fdf95b4fe6ae9bd0de6d">XSECURE_LMS_HSS_L0_SIGN_INVALID_LEN_2_ERROR</a>, <a class="el" href="group__xsecure__error__codes.html#ggacba8dc046b878afa42fdc63ce1dc2574aa8d2dfa0aff23197491bff52bcbf0916">XSECURE_LMS_HSS_L1_PUB_KEY_LMS_TYPE_1_UNSUPPORTED_ERROR</a>, <a class="el" href="group__xsecure__error__codes.html#ggacba8dc046b878afa42fdc63ce1dc2574acf8252635e76d70b0536fa4b33d8317a">XSECURE_LMS_HSS_PUB_KEY_INVALID_LEN_2_ERROR</a>, <a class="el" href="group__xsecure__error__codes.html#ggacba8dc046b878afa42fdc63ce1dc2574a5dc988f13f1f51c4c3e28ed3fee3cb69">XSECURE_LMS_HSS_SIGN_LEVEL_UNSUPPORTED_ERROR</a>, <a class="el" href="group__xsecure__error__codes.html#ggacba8dc046b878afa42fdc63ce1dc2574af5c31047d3007a3c183c1f784f3aa5b6">XSECURE_LMS_HSS_SIGN_PUB_KEY_LEVEL_MISMATCH_ERROR</a>, <a class="el" href="xsecure__lms_8h.html#a87557e3db575e6dc9ad6ddfc596a554aa2c49e5b42557925b34b58f162bb3fc31">XSECURE_LMS_NOT_SUPPORTED</a>, <a class="el" href="xsecure__lms__ots_8h.html#ac44fed4428b1bce22f588c3c913818fdab0be342315c7753f9987ad7d713b6fbd">XSECURE_LMS_OTS_NOT_SUPPORTED</a>, <a class="el" href="xsecure__lms__ots_8h.html#adf5b0f6845109ee4715a5f00c732c0b5">XSECURE_LMS_OTS_SIGN_C_FIELD_OFFSET</a>, <a class="el" href="group__xsecure__error__codes.html#ggacba8dc046b878afa42fdc63ce1dc2574a02868afd108384a2fb0ada70a7e5e66c">XSECURE_LMS_PUB_OP_FAILED_1_ERROR</a>, <a class="el" href="group__xsecure__error__codes.html#ggacba8dc046b878afa42fdc63ce1dc2574a83a91144eee447ba46ba68d051d8875c">XSECURE_LMS_PUB_OP_FAILED_ERROR</a>, <a class="el" href="group__xsecure__error__codes.html#ggacba8dc046b878afa42fdc63ce1dc2574ac0142a99044b248cf9de44cd80563c52">XSECURE_LMS_SIGN_VERIFY_BH_AND_TYPE_SHA_ALGO_MISMATCH_L0_ERROR</a>, <a class="el" href="xsecure__lms_8c.html#a292e1e3bc9bd3759b76c98cfd8196deb">XSecure_LmsLookupParamSet()</a>, <a class="el" href="xsecure__lms__ots_8c.html#a48db68f8b63048019c35a756e58d9181">XSecure_LmsOtsLookupParamSet()</a>, <a class="el" href="xsecure__lms__core_8c.html#a6b50f9fb052dd231c50ea15138f17ff7">XSecure_LmsSignatureVerification()</a>, and <a class="el" href="group__xsecure__common__apis.html#ga693c54d224d1fa8ca68b215023b2b359">XSecure_Printf</a>.</p>

<p>Referenced by <a class="el" href="group__xsecure__kat__server__apis.html#gacd410c8890a3160304bf000bf0af2031">XSecure_HssSha2256Kat()</a>, and <a class="el" href="group__xsecure__kat__server__apis.html#ga75f8f635a7d2a99f8b2011b8365a7c46">XSecure_HssShake256Kat()</a>.</p>

</div>
</div>
<a class="anchor" id="a20f145ad946cac0682c7428afe35dc8f"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int XSecure_LmsHashMessage </td>
          <td>(</td>
          <td class="paramtype">XSecure_Sha *&#160;</td>
          <td class="paramname"><em>ShaInstPtr</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">u8 *&#160;</td>
          <td class="paramname"><em>Data</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">u32&#160;</td>
          <td class="paramname"><em>DataLen</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">XSecure_ShaMode&#160;</td>
          <td class="paramname"><em>Mode</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>This function calculates the Digest of data to authenticate to initiate the process of LMS verification. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">Data</td><td>- Data to be authenticated </td></tr>
    <tr><td class="paramname">DataLen</td><td>- Length of data to be authenticated</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd><ul>
<li>XST_SUCCESS - If operation success, otherwise following errors </li>
</ul>
</dd></dl>

<p>References <a class="el" href="union_x_secure___lms_data_digest_fixed_fields__.html#a82907f08e81b5bdbe459153d407b898b">XSecure_LmsDataDigestFixedFields_::D_MESG</a>, and <a class="el" href="xsecure__lms__ots_8h.html#a434d38a2acb11f42b7fed781844eb3ee">XSECURE_LMS_MESSAGE_TO_DIGEST_PREFIX_SIZE</a>.</p>

<p>Referenced by <a class="el" href="group__xsecure__kat__server__apis.html#gacd410c8890a3160304bf000bf0af2031">XSecure_HssSha2256Kat()</a>, and <a class="el" href="group__xsecure__kat__server__apis.html#ga75f8f635a7d2a99f8b2011b8365a7c46">XSecure_HssShake256Kat()</a>.</p>

</div>
</div>
<a class="anchor" id="a6b50f9fb052dd231c50ea15138f17ff7"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int XSecure_LmsSignatureVerification </td>
          <td>(</td>
          <td class="paramtype">XSecure_Sha *&#160;</td>
          <td class="paramname"><em>ShaInstPtr</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">XPmcDma *&#160;</td>
          <td class="paramname"><em>DmaPtr</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">XSecure_LmsSignVerifyParams *&#160;</td>
          <td class="paramname"><em>LmsSignVerifyParams</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>This function performs LMS level signature verification. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">Data</td><td>- Data to be authenticated, will be passed to LMS OTS signature verification </td></tr>
    <tr><td class="paramname">DataLen</td><td>- Length of data to be authenticated, will be passed to LMS OTS signature verification </td></tr>
    <tr><td class="paramname">PreHashedMsg</td><td>- If TRUE, then Data contains digest, if FALSE contains raw msg to be authenticated </td></tr>
    <tr><td class="paramname">LmsSign</td><td>- Pointer to LMS signature buffer for a tree </td></tr>
    <tr><td class="paramname">LmsSignLen</td><td>- Length of LMS signature </td></tr>
    <tr><td class="paramname">ExpectedPubKey</td><td>- Pointer to expected LMS public key </td></tr>
    <tr><td class="paramname">PubKeyLen</td><td>- Length of LMS public key</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>XST_SUCCESS - if operation success, otherwise following errors </dd></dl>
<p>Used to find 32 byte value from LMS signature array</p>
<ol type="1">
<li>Public key checks 1, 2a, 2b - Length should be atleast 8 bytes to be able to fetch Type of algo used for LMS &amp; LMS OTS 2c - Once Type is extracted, set m 2d - Public key should be == 24 + m otherwise stop process and raise error</li>
</ol>
<p>6.1: Standard recommends less than 8 is not valid, this check covers 4a.1</p>
<p>6.2a Extracting Public key LMS Type, Big Endian to Little Endian</p>
<p>6.2b Extracting Public key LMS OTS Type, Big Endian to Little Endian</p>
<p>6.2d: Length of key check, should be equal to 24 + m, covers 4a.2b</p>
<p>6a. Signature checks 1 - Length should be atleast 8 bytes long 2a - Parse 'q', OTS 'Type' 2b,2c - OTS 'Type' should match with pub key OTS 'Type' 2d - Set 'n', 'p' from signature OTS 'Type', 2d - Length should be AT LEAST (12 + n * (p + 1)), this is to check if signature has enough for OTS signature component 2e,2f - OTS signature [4 to (7 + n (p + 1))] 2g - Set LMS signature Type [(8 + n (p + 1)) to (11 + n (p + 1)) bytes], LMS signature Type should match with LMS public 'Type' 2h - Set 'm', 'h' according to LMS signature Type 2i - 'q' &gt;= 2^h or LMS signature Length != 12 + n * (p + 1) + m * h) then error</p>
<p>6a.1 Length should be at least 8 bytes</p>
<p>6a.2a parse q from LMS signature, Big Endian to Little Endian</p>
<p>6.2e parse I from LMS Public key</p>
<p>6a.2d: Total signature length check, should have at least LMS OTS signature required Length to proceed</p>
<p>6a.2h: Fetch the params for LMS signature from Type of signature, if not a valid/supported Type return error</p>
<p>6a.2i: Leaf nodes for a tree range from [0 to (2^h - 1)], to be a valid node number LMS signature length should be 12 + (n * (p + 1)) + (m * h) bytes</p>
<p>6a.3: LMS OTS candidate public key 'Kc'</p>
<p>6.4, Now that we have arrived at root value, compare with expected to see if it matches, comparision should be single glitch resistant</p>

<p>References <a class="el" href="union_x_secure___lms_pub_key_tmp__.html#ac4436f40127798b3bb9261cc09f0a912">XSecure_LmsPubKeyTmp_::D</a>, <a class="el" href="struct_x_secure___lms_param.html#a1fb9b3a0d2a2674d9f5cc1bb386d6eb0">XSecure_LmsParam::h</a>, <a class="el" href="union_x_secure___lms_pub_key_tmp__.html#a92de8c48812ac0eb7b43562f44dfae5c">XSecure_LmsPubKeyTmp_::half_node_number</a>, <a class="el" href="union_x_secure___lms_pub_key_tmp__.html#a062cfe1349c7e202d086a4bfad9c3867">XSecure_LmsPubKeyTmp_::I</a>, <a class="el" href="union_x_secure___lms_data_digest_fixed_fields__.html#aaa6fe65d46b47201f9c1759148669987">XSecure_LmsDataDigestFixedFields_::I</a>, <a class="el" href="struct_x_secure___lms_param.html#a87a19a975a59e9fc7fa8d10fd4ac6ab4">XSecure_LmsParam::m</a>, <a class="el" href="struct_x_secure___lms_param.html#a42a5db17d1cf707af99fddeb1a50315e">XSecure_LmsParam::mh</a>, <a class="el" href="union_x_secure___lms_data_digest_fixed_fields__.html#aba71ec3514983a2b92250d07d56441fb">XSecure_LmsDataDigestFixedFields_::q</a>, <a class="el" href="union_x_secure___lms_pub_key_tmp__.html#ac708ae7db6633d104bd8e6d19b0c2ed4">XSecure_LmsPubKeyTmp_::Tmp</a>, <a class="el" href="xsecure__lms_8h.html#a87557e3db575e6dc9ad6ddfc596a554aa2c49e5b42557925b34b58f162bb3fc31">XSECURE_LMS_NOT_SUPPORTED</a>, <a class="el" href="xsecure__lms__ots_8h.html#ac44fed4428b1bce22f588c3c913818fdab0be342315c7753f9987ad7d713b6fbd">XSECURE_LMS_OTS_NOT_SUPPORTED</a>, <a class="el" href="group__xsecure__error__codes.html#ggacba8dc046b878afa42fdc63ce1dc2574a3222b24cc7e8f18f476ee02b2bb7ba5e">XSECURE_LMS_OTS_PUB_KEY_LMS_OTS_SIGN_TYPE_MISMATCH_ERROR</a>, <a class="el" href="xsecure__lms__ots_8h.html#a57cc8baa8a82a27f721b46f46a21b159">XSECURE_LMS_OTS_SIGN_TYPE_FIELD_OFFSET</a>, <a class="el" href="group__xsecure__error__codes.html#ggacba8dc046b878afa42fdc63ce1dc2574a37b05f89e934ac2aa17d94e35f8dd41b">XSECURE_LMS_PUB_KEY_AUTHENTICATION_FAILED_ERROR</a>, <a class="el" href="group__xsecure__error__codes.html#ggacba8dc046b878afa42fdc63ce1dc2574aebb63f40baaa306c4a9893bf6a870768">XSECURE_LMS_PUB_KEY_AUTHENTICATION_GLITCH_ERROR</a>, <a class="el" href="group__xsecure__error__codes.html#ggacba8dc046b878afa42fdc63ce1dc2574a81f1e66a1def2c74088c6379ebb1dec0">XSECURE_LMS_PUB_KEY_LMS_SIGN_TYPE_MISMATCH_ERROR</a>, <a class="el" href="group__xsecure__error__codes.html#ggacba8dc046b878afa42fdc63ce1dc2574a7f5d9c0c614cfee7db08b6f2055ba01c">XSECURE_LMS_PUB_KEY_UNSUPPORTED_TYPE_1_ERROR</a>, <a class="el" href="group__xsecure__error__codes.html#ggacba8dc046b878afa42fdc63ce1dc2574a2c7f67cb007825061cea0a8122d147ec">XSECURE_LMS_SIGN_EXPECTED_PUB_KEY_LEN_2_ERROR</a>, <a class="el" href="group__xsecure__error__codes.html#ggacba8dc046b878afa42fdc63ce1dc2574aa21082e86fb0821385f0008058ae4d2d">XSECURE_LMS_SIGN_INVALID_NODE_NUMBER_ERROR</a>, <a class="el" href="group__xsecure__error__codes.html#ggacba8dc046b878afa42fdc63ce1dc2574a98a27e16a848106c4ab8d9ebb79bd4c0">XSECURE_LMS_SIGN_LEN_1_ERROR</a>, <a class="el" href="group__xsecure__error__codes.html#ggacba8dc046b878afa42fdc63ce1dc2574ae6754836b479318194650d53a7c9365d">XSECURE_LMS_SIGN_LEN_2_ERROR</a>, <a class="el" href="group__xsecure__error__codes.html#ggacba8dc046b878afa42fdc63ce1dc2574a471748e6250c24aceb61a32058dd3b90">XSECURE_LMS_SIGN_LEN_3_ERROR</a>, <a class="el" href="group__xsecure__error__codes.html#ggacba8dc046b878afa42fdc63ce1dc2574a30bdd1e0d54a423fbea077ec00c4d80f">XSECURE_LMS_SIGN_OTS_OP_ERROR</a>, <a class="el" href="group__xsecure__error__codes.html#ggacba8dc046b878afa42fdc63ce1dc2574a3838867affba78273af36014f0b9760e">XSECURE_LMS_SIGN_UNSUPPORTED_OTS_TYPE_1_ERROR</a>, <a class="el" href="group__xsecure__error__codes.html#ggacba8dc046b878afa42fdc63ce1dc2574a9ea2747433f1e061789903601a1cf051">XSECURE_LMS_SIGN_UNSUPPORTED_TYPE_1_ERROR</a>, <a class="el" href="group__xsecure__error__codes.html#ggacba8dc046b878afa42fdc63ce1dc2574a9d64d3ba385e778eb5c2311152ffd191">XSECURE_LMS_SIGN_VERIF_SHA_DIGEST_INTR_EVEN_FAILED_ERROR</a>, <a class="el" href="group__xsecure__error__codes.html#ggacba8dc046b878afa42fdc63ce1dc2574a564d39418f8c35c24e44b43c54d757aa">XSECURE_LMS_SIGN_VERIF_SHA_DIGEST_INTR_ODD_FAILED_ERROR</a>, <a class="el" href="group__xsecure__error__codes.html#ggacba8dc046b878afa42fdc63ce1dc2574a08499b9b367065551b28ea39c50b351c">XSECURE_LMS_SIGN_VERIF_SHA_DIGEST_LEAF_FAILED_ERROR</a>, <a class="el" href="xsecure__lms_8c.html#a292e1e3bc9bd3759b76c98cfd8196deb">XSecure_LmsLookupParamSet()</a>, <a class="el" href="xsecure__lms__ots_8c.html#a48db68f8b63048019c35a756e58d9181">XSecure_LmsOtsLookupParamSet()</a>, and <a class="el" href="group__xsecure__common__apis.html#ga693c54d224d1fa8ca68b215023b2b359">XSecure_Printf</a>.</p>

<p>Referenced by <a class="el" href="xsecure__lms__core_8h.html#a112da8c38a140d02852bd8f93ab78e2f">XSecure_HssFinish()</a>, <a class="el" href="xsecure__lms__core_8h.html#a981b22fbc50d9cd6f91c16604754f078">XSecure_HssInit()</a>, <a class="el" href="group__xsecure__kat__server__apis.html#gad7b08bfc183e838bb6d65a94b96ea218">XSecure_LmsSha2256Kat()</a>, and <a class="el" href="group__xsecure__kat__server__apis.html#gafc77ae5d3ebc5c665ee997c554612390">XSecure_LmsShake256Kat()</a>.</p>

</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
	<p class="footer">&copy; Copyright 2015-2022 Xilinx, Inc. All Rights Reserved.</p>
	<p class="footer">&copy; Copyright 2022-2023 Advanced Micro Devices, Inc. All Rights Reserved.</p>
</div>
</body>
</html>
